package cn.tedu.analyse.controller;

import cn.tedu.analyse.response.JsonResult;
import cn.tedu.analyse.service.LikesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/Likes")
@Api(tags = "点赞")
public class LikesController {
    @Autowired
    private LikesService likesService;

    @ApiOperation("创建评论点赞")
    @PostMapping("create/{commentId}/{userId}")
    public JsonResult createLikes(@PathVariable Long commentId ,@PathVariable Long userId){
        log.debug("创建点赞，commentId：{},userId:{}",commentId,userId);
        likesService.createLikes(commentId,userId);
        log.debug("点赞创建成功,commentId：{},userId:{}",commentId,userId);
        return JsonResult.ok();
    }
    @ApiOperation("取消评论点赞")
    @DeleteMapping("delete/{commentId}/{userId}")
    public JsonResult deleteLikes(@PathVariable Long commentId ,@PathVariable Long userId){
        log.debug("删除点赞，commentId：{},userId:{}",commentId,userId);
        likesService.deleteLikes(commentId,userId);
        return JsonResult.ok();
    }
}
